var backuserlist = {
		
		curPage : 1,
		pageSize : 20,
		deviceIds:'',
		
		initPage : function(){
			backuserlist.initBtn();
			backuserlist.getDatalist(0);
		},
		
		initBtn : function(){
			backuserlist.deviceIds = util.getQueStr("ids");
			
			$("#qryBtn").click(function(){
				backuserlist.getDatalist(0);
			});
			$("#cancelBtn").click(function(){
				window.parent.art.dialog({id:'ww'}).close();
			});
			$("#cancelBtn").click(function(){
				window.parent.art.dialog({id:'ww'}).close();
			});
			$("#confirmBtn").click(function(){
				var userId = $("input[type='radio']:checked").val();
				if(typeof(userId) == "undefined"){
					$.dialog({
						icon: "warning",
					    title: '警告',
					    content: '请选择代理商',
					 });
				}else{
					var params = {};
					params['userId'] = userId;
					params['deviceIds'] = backuserlist.deviceIds;
					usermanager.allcationDevice(params, function(data){
						window.parent.deviceList.getDeviceList(0);
						window.parent.art.dialog({id:'ww'}).close();
					}, function(){});
				}
			});
		},
		
		getDatalist : function(pageIndex){
			$('#backuserlist').html('<tr><td colspan="10"  style="text-align:center;">正在查询,请稍后...</td></tr>');
			$('#backuserlistpage').html("");
			pageIndex=(pageIndex==null)? 0:pageIndex;
			var params = {};
			params['curPage'] = pageIndex + 1;
			params['pageSize'] = backuserlist.pageSize;
			params['userType'] = "2";
			params['nickName'] = $("#nickName").val();
			params['userLevel'] = parseInt(util.getCookieValue('userLevel'))+1;
			usermanager.getUserList(params, backuserlist.getbackuserlist_Succ, backuserlist.getbackuserlist_error);
			backuserlist.curPage = pageIndex + 1;
		},
		
		getbackuserlist_Succ : function(data){
			if(data && data.retCode == 0){
				var _html = '';
				if(data.data && data.data.length > 0){
					for(var key in data.data){
						var item = data.data[key];
						var userLevel = item.userLevel;
						var levelStr = '';
						if(userLevel==2){
							levelStr = '一级代理';
						}else if(userLevel==3){
							levelStr = '二级代理';
						}else if(userLevel==4){
							levelStr = '三级代理';
						}
						if(item.account=='admin'){
							continue;
						}
						_html += '<tr><td class="tal"><input type="radio" name="beLongUser" value="'+item.userId+'"> &nbsp;'+((parseInt(backuserlist.curPage)-1)*backuserlist.pageSize + (parseInt(key)+1))+'</td>';
						_html += '<td class="tal">'+item.nickName+'</td><td>'+levelStr+'</td>';
						_html += '</tr>';
					}
					$('#backuserlist').html(_html);
					if(data.page){
						util.paginationPage($('#backuserlistpage'), data.page.totalPage, parseInt(data.page.curPage-1), backuserlist.getDatalist,true);
					}
				}else{
					$('#backuserlist').html('<tr  align="center"><td colspan=10>暂无数据.</td></tr>');
					$('#backuserlistpage').html("");
				}
			}else{
				$.dialog( {
					title : '错误',
					icon : 'error',
					content : '获取错误！',
					time : 3
				});
			}
		},
		
		getbackuserlist_error:function(data){
			window.location.reload();
		},
		
		
};
backuserlist.initPage();
